//
//  FIBaseViewController.m
//  Magpie
//
//  Created by 100TV protocal on 12-11-13.
//
//

#import "FIBaseViewController.h"
#import "ASIHTTPRequest.h"

@interface FIBaseViewController ()

@end

@implementation FIBaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

BOOL isValidResponse(id response, NSString** errorMsg){
	assert(*errorMsg!=nil);
	BOOL ret=NO;
	if(response==nil){
		*errorMsg=@"未知错误。";
		return ret;
	}
	if([response isKindOfClass:[NSError class]]){
		NSError* error=(NSError*)response;
		NSLog(@"%@",error);
		if([NetworkRequestErrorDomain isEqualToString:[error domain]]){
			*errorMsg=@"网络出错。";
		}else{
			*errorMsg=[error localizedDescription];
		}
		return ret;
	}
	ret=YES;
	return ret;
}


@end
